Skip to content

feat: GUI からのシェルコマンド実行の追加 (#17)#21

Merged
ktmage merged 6 commits into
developmentfrom
feature/17-shell-command-execution
Feb 28, 2026
Merged

feat: GUI からのシェルコマンド実行の追加 (#17)#21
ktmage merged 6 commits into
developmentfrom
feature/17-shell-command-execution

Conversation

@ktmage

@ktmage ktmage commented Feb 28, 2026

Copy link
Copy Markdown
Owner

概要

チャット入力欄で ! プレフィクスを付けてシェルコマンドを実行できる機能を追加。
結果はターミナル風の専用 UI(ShellResultView)で表示される。

Closes #17

変更内容

シェルコマンド実行の基盤

  • opencode-client.tsexecuteShell() メソッドを追加
  • Webview ↔ Extension Host 間の executeShell メッセージタイプを追加
  • chat-view-provider.ts にハンドラーを追加
  • InputArea! プレフィクスを検出し、シェルモードインジケーター・専用プレースホルダーを表示
  • ロケールキー追加(input.shellMode, input.placeholder.shell, shell.title

ShellResultView コンポーネント

  • $ command プロンプト + 出力をターミナル風に一体表示する新コンポーネント
  • 完了・実行中・pending・エラーの各状態に対応
  • デフォルト展開、ヘッダークリックで折りたたみ可能

ユーザー吹き出しの非表示

  • useMessages で user / assistant 両メッセージをシェルとしてタグ付け
  • シェルコマンドのユーザーメッセージは吹き出しを非表示(ShellResultView の $ command で代替)
  • シェルの assistant メッセージは TextPart を非表示にし、ShellResultView のみ描画

CSS スコープ修正

  • Markdown 用 CSS セレクタを .content :global(.markdown) に限定
  • TextPartViewclassName="markdown" を追加
  • ShellResultView 等の子コンポーネントへのスタイル漏れを防止

テスト(49ファイル / 653テスト)

  • ShellResultView 単体テスト(14テスト): 各状態、折りたたみ、複数エントリ、空パーツ、フィルタリング
  • useMessages フックテスト(5テスト): markPendingShell, isShellMessage, フラグライフサイクル
  • MessageItem テスト(3テスト): ShellResultView 描画、テキスト非表示、ユーザー吹き出し非表示
  • シナリオテスト(16テスト): 入力送信、モードインジケーター、結果表示、エラー、実行中

チェックリスト

  • npm run build passes
  • npm test passes

ktmage added 5 commits March 1, 2026 02:34
- Add executeShell() method to opencode-client.ts
- Add executeShell message type to webview protocol
- Add handler in chat-view-provider.ts
- Detect ! prefix in InputArea and route to onShellExecute
- Add shell mode indicator and placeholder
- Add locale keys for shell mode (en/ja)
- Create ShellResultView with $ prompt, output display, spinner
- Support completed/running/pending/error states
- Wire onShellExecute and isShellMessage through AppContext
- Connect handleShellExecute in App.tsx
- Track both user and assistant messages as shell in useMessages
- Hide user bubble for shell commands (ShellResultView shows $ command)
- Render ShellResultView instead of ToolPartView for shell assistant messages
- Filter out synthetic TextParts for shell messages
- Add className='markdown' to TextPartView span element
- Change .content pre/code/ul/ol/li/p selectors to .content :global(.markdown) variants
- Prevents Markdown styles from leaking into ShellResultView and other child components
- Add ShellResultView unit tests (14 tests): states, toggle, multiple entries, edge cases
- Add useMessages shell tracking tests (5 tests): markPendingShell, isShellMessage, flag lifecycle
- Add MessageItem shell tests (3 tests): ShellResultView rendering, text hiding, user bubble hiding
- Add scenario tests (16 tests): input, mode indicator, result display, error, running state
- Update MessageItem/MessagesArea tests with AppContextProvider wrapper
@ktmage ktmage changed the title Feature/17-shell-command-execution feat: GUI からのシェルコマンド実行の追加 (#17) Feb 28, 2026
@ktmage ktmage marked this pull request as ready for review February 28, 2026 17:42
@ktmage ktmage linked an issue Feb 28, 2026 that may be closed by this pull request
@ktmage ktmage merged commit f5d7744 into development Feb 28, 2026
1 check passed
@ktmage ktmage deleted the feature/17-shell-command-execution branch March 1, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GUI からのシェルコマンド実行の追加

1 participant